﻿using System.Collections.Generic;
using System.Configuration;
using System.Web.Mvc;
using DevTrends.MvcDonutCaching;
using ECG.Common;
using ECG.DAL;
using ECG.WebUI.Models;

namespace ECG.WebUI.Controllers
{
    public class ProductByProviderController : Controller
    {
        //
        // GET: /ProductByProvider/
        [DonutOutputCache(Duration = 3600, VaryByParam = "Provider;ProviderName;page")]
        public ActionResult Index(string Provider = "", string ProviderName = "", int page = 1)
        {
            var itemsPerPage = int.Parse(ConfigurationManager.AppSettings["ItemsPerPageDefault"]);
            var totalPage = 0;
            var model = ProductDb.GetAllProducByProvider(page, itemsPerPage, ref totalPage, Provider) ?? new List<ProductRateByCateTopListPagingDto>();
            ViewBag.PageInfo = new PageInfo { CurrentPage = page, PageSize = itemsPerPage, TotalPages = totalPage };
            ViewBag.ProviderName = ProviderName;
            return View(model);
        }

    }
}
